import 'package:flutter/material.dart';
import 'package:common/global/style.dart';

class SettingItem extends StatelessWidget {
  final String label;
  final bool showArrow;
  final double itemHeight;
  final Color backgroundColor;
  final double paddingStart;
  final double paddingEnd;
  final Function onTap;
  final double labelTextSize;
  final Widget trailingWidget;

  SettingItem({
    @required this.label,
    @required this.onTap,
    this.showArrow = true,
    this.itemHeight = 45,
    this.backgroundColor = Colors.white,
    this.paddingStart = 50,
    this.paddingEnd = 50,
    this.labelTextSize = 15,
    this.trailingWidget,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsetsDirectional.only(end: paddingEnd, start: paddingStart),
      height: itemHeight,
      alignment: AlignmentDirectional.centerStart,
      decoration: BoxDecoration(color: backgroundColor),
      child: GestureDetector(
        behavior: HitTestBehavior.opaque,
        onTap: onTap,
        child: Row(
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Expanded(
                child: Text(
              label, textScaleFactor: 1,
              style:
                  TextStyle(color: TColor.textBlack, fontSize: labelTextSize),
            )),
            if (trailingWidget != null) trailingWidget,
            if (showArrow)
              SizedBox(
                width: 10,
              ),
            if (showArrow)
              Icon(
                Icons.keyboard_arrow_right,
                size: 20,
                color: TColor.textBlack,
              )
          ],
        ),
      ),
    );
  }
}
